<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  <title>登录</title>
  <link rel="stylesheet" href="./libs/element-ui/lib/theme-chalk/index.css">

  <style>
    .login-img {
      height: 100vh;
      width: 100%;
      background: url('images/login.png') no-repeat 0 0 / cover;
    }

    .login-detail {
      position: absolute;
      width: 480px;
      height: 400px;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      background-color: #fff;
      padding: 60px 110px;
      box-sizing: border-box;
    }

    h2 {
      text-align: center;
      font-size: 20px;
      font-weight: 400;
      font-family: 'PingFangSC-Medium';
      padding-bottom: 22px;
    }

    .user-name {
      height: 58px;
      text-align: center;
      border-bottom: 1px solid #eee;
    }

    input {
      margin-top: 36px;
      border: none;
      width: 100%;
      text-align: center;
      outline: none;
      font-size: 14px;
      font-family: 'PT Sans', sans-serif;
    }

    .submit-btn {
      height: 34px;
      background-color: #e23928;
      display: inline-block;
      width: 100%;
      margin-top: 50px;
      text-align: center;
      line-height: 34px;
      color: #fff;
      font-size: 14px;
      font-family: 'PT Sans', sans-serif;
      cursor: pointer;
    }
  </style>
</head>

<body style="margin: 0">
  <div class="login-img" id="app">
    <div class="login-detail">
      <h2>流程引擎flowable应用登录</h2>
      <p class="user-name">
        <input type="text" v-model="userId" placeholder="请输入用户名" maxlength="80" />
      </p>
      <p class="user-name">
        <input type="password" v-model="password" @keyup.enter="login" placeholder="请输入密码" maxlength="80" />
      </p>
      <el-botton class="submit-btn" v-loading="loading" @click="login">登录</el-botton>
    </div>
  </div>
  <!-- <script src="https://cdn.jsdelivr.net/npm/vue"></script> -->
  <!-- <script src="https://cdn.bootcss.com/blueimp-md5/2.12.0/js/md5.min.js"></script> -->
  <!-- <script src="https://unpkg.com/axios/dist/axios.min.js"></script> -->
  <!-- <script src="https://unpkg.com/element-ui/lib/index.js"></script> -->
  <script src="./libs/vue.min.js"></script>
  <script src="./libs/axios.min.js"></script>
  <script src="./libs/element-ui/lib/index.js"></script>
  <script>
    var app = new Vue({
      el: '#app',
      data: {
        userId: '',
        password: '',
        loading: false
      },
      methods: {
        login() {
          let self = this
          this.loading = true
          // var pwd = md5(this.password + 'flowableSalt'),
          var params = {
            userId: this.userId.trim(),
            password: this.password
          }
          var origin = window.location.origin
          // axios.post('http://flowable.ripples-uat.crcloud.com:8083/static/task/apis/adminManagement/login',params)
          axios.post(origin + '/static/task/apis/adminManagement/login', params).then(function (res) {
            self.loading = false
            if (res.data) {
              let data = res.data
              localStorage.Authorization = data.token
              localStorage.tenant = data.tenant
              localStorage.ExpiresIn = 5999
              localStorage.RefreshTime = new Date()
              // window.location.href = 'http://flowable.ripples-uat.crcloud.com:8083/#/home'
              window.location.href = origin + '/#/home'
            }
          }).catch(function (error) {
            self.loading = false
            self.$message({
              message: error.response.data.message,
              type: 'error'
            })
          })
        }
      }
    })
  </script>
</body>

</html>